﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Utility
{
    public static class Parse
    {
        public static string[][] ToJaggedArray(string str, char delimiterRow = '\n', char delimiterCol = ',')
        {
            try
            {
                return str.Split(delimiterRow).Select(i => i.Split(delimiterCol).ToArray()).ToArray();
            }
            catch
            {
                return null;
            }
        }

        public static string[] Split(string str, char delimiter = ',', string remove = @"\t|\n|\r| ", string replace = "")
        {
            return Replace(str, remove, replace).Split(delimiter);
        }

        public static string Replace(string value, string remove = @"\t|\n|\r| ", string replace = "")
        {
            return Regex.Replace(value, remove, replace);
        }
    }
}
